In order to store or transmit a digital image with high efficiency, it is necessary to compressively coding the digital image. As a method for compressively coding a digital image, there is a waveform coding method such as subband coding, wavelet coding, or fractal coding, besides discrete cosine transform (DCT). In coding an image, the image is compressed by removing redundant data within a frame when the image has similar portions within the frame, or by removing redundant data between frames, such as still portions, from continuous display frames, and then the compressed image is coded.
As a method for removing redundant information within a frame, there is a method called intra-frame prediction. In this method, a difference between a portion to be coded and an adjacent portion that has already been coded is obtained to express the portion to be coded as a difference signal, and this difference signal is subjected to waveform coding.
Further, as a method for removing redundant image information between adjacent frames, there is a method of performing inter-frame prediction using motion compensation. In this method, a difference between a pixel value of a pixel in a current frame and a pixel value of a pixel in a previous frame is obtained to express the pixel in the current frame as a difference signal, and this difference signal is subjected to waveform coding.
An example of a conventional image predictive coding apparatus using the above-described method of performing inter-frame prediction will be described with reference to FIG. 16. FIG. 16 is a block diagram illustrating the construction of a typical image coding apparatus 1500.
With reference to FIG. 16, the image coding apparatus 1500 comprises a blocking unit 1 for dividing an input image into plural macroblocks each having a size of 16×16 pixels; a subtracter 2 for calculating a difference value s1 between a target macroblock to be coded and a predictive macroblock corresponding to the target macroblock; a switch 3 which is turned ON and OFF according to a judgement result from a skip macroblock judgement unit 4; a skip macroblock judgement unit 4 for judging whether the target macroblock is a skip macroblock to be replaced with a macroblock at the same position in a just previous frame, or the difference value s1 should be coded, according to an absolute value of the difference value s1 and a quantization parameter supplied from the outside, and turning ON or OFF the switch 3 according to a judgement result; a compressive coding unit 5 for compressively coding the difference value s1; a local decoding unit 9 for performing local decoding on the basis of a quantization factor outputted from the compressive coding unit 5; and a local predictive image generation unit 12 for generating a predictive macroblock from the output of the local decoding unit 9.
The compressive coding unit 5 comprises a frequency converter 6 for converting the difference value s1 into a frequency domain signal; a quantizer 7 for quantizing the output of the frequency converter 6 using the quantization parameter supplied from the outside; and a variable-length encoder 8 for variable-length coding the output of the quantizer 7 (quantization factor), or multiplexing a skip macroblock signal s2 outputted from the skip macroblock judgement unit 4, with data obtained by variable-length coding a difference signal of another macroblock, and outputting a code string.
The local decoding unit 9 comprises an inverse quantizer 10 for inversely quantizing the output of the quantizer 7 (quantization factor); and an inverse frequency converter 11 for converting the output of the inverse quantizer 10 (frequency domain signal) into a space domain signal.
The local predictive image generation unit 12 comprises a frame memory 14 for holding data obtained by adding the output of the local decoding unit 9 (local decoded data) and the output of the predictive image generation unit 13 (predictive macroblock); and a predictive image generator 13 for generating a predictive macroblock.
Hereinafter, the operation of the image coding apparatus 1500 constituted as described above will be described.
An input image is divided into plural macroblocks by the blocking unit 1. Then, a difference value s1 between a target macroblock to be coded and a predictive macroblock corresponding to the target macroblock is obtained by the subtracter 3, and a judgement as to whether this macroblock is a skip macroblock or not is carried out by the skip macroblock judgement unit 4, using an absolute value of this difference value s1 and a quantization parameter supplied from the outside.
Hereinafter, the operation of the skip macroblock judgement unit 4 will be described with reference to FIG. 17. Initially, a mean absolute value X of the difference value s1 of the target macroblock, which is output from the subtracter 2, is obtained (step S1600), and the obtained mean absolute value X is compared with a threshold value THR_L which is obtained by multiplying the quantization parameter with a prescribed value (step S1601). When the mean absolute value X is larger than the threshold value THR_L, the target macroblock is judged as an inter macroblock (step S1602), and the difference value s1 is coded. When the mean absolute value X is smaller than the threshold value THR_L, the target macroblock is judged as a skip macroblock (step S1603). That is, macroblocks judged as skip macroblocks are those to be coded in the previous frame and the target frame, and their neighboring macroblocks with less motion or no notion (still macroblocks).
When the skip macroblock judgement unit 4 judges that the target macroblock is not a skip macroblock, the difference value s1 is output to the compressive coding unit 5 by the switch 3. In the compressive coding unit 5, the difference value s1 is converted into a frequency domain signal by the frequency converter 6, and the frequency domain signal is quantized by the quantizer 7 using the quantization parameter supplied from the outside. Further, the output of the quantizer 7 (quantization factor) is variable-length coded by the variable length encoder 9. The output of the quantizer 7 is locally decoded by the local decoding unit 9, and the locally decoded data is used for generation of a predictive image (predictive macroblock) by the local predictive image generation unit 12.
When the skip macroblock judgement unit 4 judges that the target macroblock is a skip macroblock, a skip macroblock signal s2 is output from the skip macroblock judgement unit 4 to the variable length encoder 8. In the variable length encoder 8, the skip macroblock signal s2 is multiplexed with data which is obtained by variable-length coding a difference signal of another macroblock, and a result is output as a code string.
In this way, a still picture is determined while coding an image, and the determined still picture is coded so as to have high image quality.
The image coding method described with respect to FIG. 16 is a one-pass coding method in which an image signal to be coded is input to an encoder only once. In this method, the target image signal can be coded immediately after the inputting, resulting in real-time coding.
In contrast with the one-pass coding method, there is a two-pass coding method in which a target image signal is once coded, and the coded signal is again coded using information of the first-time coding. Although this two-pass coding method enables coding using the information of the first-time coding, it requires a longer time for coding as compared with the one-pass coding.
The above-described conventional image coding apparatus and method are disclosed in, for example, Japanese Published Patent Applications Nos. 2000-188735 and 2000-125301.
In the conventional coding method, however, since the whole image is coded, the amount of generated codes is undesirably increased. So, by performing coding of the difference value using inter-frame prediction that has conventionally been employed, or by performing coding such that the target macroblock judged as a skip macroblock is replaced with a macroblock in the previous frame, the amount of bits generated in coding the target frame is reduced as compared with coding which does not perform inter-frame prediction. Especially, the coding process using inter-frame prediction provides a great effect in compression efficiency, for a still image or an image having many still portions.
Furthermore, according to the conventional coding method, in a still image or an image having many still portions, inter-frame residual signals are hardly generated in frames other than the first frame of the still image, leading to a problem that skip macroblocks which refer to the just-previous frame are increased. At this time, if degradation in image quality (coding error) due to coding of the first still frame is sufficiently small, an increase in image quality of the following still frames that refer to the first still frame can be expected. However, when the coding error of the first still frame is considerable, this coding error adversely affects the whole still part that refers to the first still frame, and degradation in image quality is not suppressed. In order to prevent such degradation in image quality, it is necessary to reduce the skip macroblocks, or perform quantization with a reduced quantization scale.